﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Pong_Xvna
{
    public class SpriteManager : Manager
    {
        protected Sprite[] unit;
        protected int nUnit;
        protected Sprite map;
        public SpriteManager(Game game)        
        {
            
            nUnit = 4;
            unit = new Sprite[nUnit];
            unit[3] = new RedCircle(game, new Vector2(350, 200), Vector2.Zero);
            unit[0] = new Pad(game, new Vector2(0, 300), Vector2.Zero, 0);
            unit[1] = new AIPad(game, new Vector2(780, 300), Vector2.Zero);
            unit[2] = new Ball(game, new Vector2(30, 330), new Vector2(5, 0));
            map = new Map(game, Vector2.Zero, Vector2.Zero);
            
            for (int i = 0; i < nUnit; i++)
            {
                unit[i].Game1 = game;
            }
        }
        public Sprite ProductUnit(int idx)
        {
            Sprite sp = null;
            if (idx >= 0 && idx < nUnit)
            {
                sp = unit[idx].Clone();
            }
            return sp;
        }
        public Sprite ProductUnit(string strName)
        {
            Sprite sp = null;
            switch (strName)
            {
                case "Pad" :
                    sp = ProductUnit(0);
                    break;
                case "AIPad":
                    sp = ProductUnit(1);
                    break;
                case "Ball":
                    sp = ProductUnit(2);
                    break;
                case "RedCircle":
                    sp = ProductUnit(3);
                    break;
            }
            return sp;
        }
    }
}
